package com.hyxt.api;

import com.hyxt.DO.AlarmInfo;
import com.hyxt.DO.GPSInfo;
import com.hyxt.DO.WarningInfo;
import com.hyxt.utils.DataValue;

import java.io.IOException;
import java.util.Date;
import java.util.List;

public interface HbaseCRUD {
    /**
     *  增加一条数据
     * @param tableName
     * @param gpsinfo
     * @return
     */
    public int putData(String tableName, GPSInfo gpsinfo) throws IOException;

    /**
     *
     * @param tableName
     * @param gpsinfo
     * @return
     * @throws Exception
     */
    public int putGPSData(String tableName, GPSInfo gpsinfo) throws Exception;
    public int putTestData(String tableName, GPSInfo gpsinfo) throws Exception;

    /**
     *添加多条数据
     * @param tableName
     * @param rows
     * @return
     */
    public int putListData(String tableName, List<DataValue> rows);

    /**
     * 删除一条数据
     * @param tableName
     * @param rowKey
     * @throws IOException
     */
    public void deleteRow(String tableName, String rowKey) throws IOException;

    /**
     * 查询一行数据
     * @param tableName
     * @param rowKey
     * @return
     * @throws IOException
     */
    public List<DataValue> selectRow(String tableName, String rowKey) throws IOException;
    public String getMileage(String rowKey) throws IOException;

    /**
     * 历史轨迹查询
     * @param vehicleID 车辆id
     * @param startTime 起始时间
     * @param endTime 结束时间
     * @return
     * @throws IOException
     * @throws java.text.ParseException
     */
    public List<GPSInfo> scanHistroyDate(String vehicleID, Date startTime, Date endTime) throws IOException, java.text.ParseException;
    public GPSInfo getLastPoint(String vehicleID, Date startTime, Date endTime) throws IOException, java.text.ParseException;
    public GPSInfo getLastPointByID(String vid, Date startTime, Date endTime);

    /**
     * 计算车辆辆时间段内行驶的距离
     * @param vid 车辆id
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @return
     */
    public double getDayMileageByVid(String vid, Date startTime, Date endTime);

    /**
     * 历史报警查询
     * @param vehicleID 车辆id
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @return
     * @throws IOException
     * @throws java.text.ParseException
     */
    public List<AlarmInfo> scanAlarmHistroyDate(String vehicleID, Date startTime, Date endTime) throws IOException, java.text.ParseException;

    /**
     * 查询历史预警信息
     * @param vehicleID 车辆id
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @return
     * @throws IOException
     * @throws java.text.ParseException
     */
    public List<WarningInfo> scanWarnHistroyDate(String vehicleID, Date startTime, Date endTime) throws IOException, java.text.ParseException;

    /**
     * 定时定位查询
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @param minLon  最小经度
     * @param minLat 最小纬度
     * @param maxLon 最大经度
     * @param maxLat 最大纬度
     * @return
     * @throws java.text.ParseException
     * @throws IOException
     */
    public List<GPSInfo> scanAreaQuery(Date startTime, Date endTime, double minLon, double minLat, double maxLon, double maxLat) throws java.text.ParseException, IOException;

    /**
     *
     * @param orgcode
     * @param startTime
     * @param endTime
     * @throws IOException
     */
    public void deleteOldData(String orgcode, Date startTime, Date endTime) throws IOException;

    /**
     *
     * @param filename
     * @param buff
     * @return
     * @throws IOException
     */
    public int loadFileToHBase(String filename, byte[] buff) throws IOException;

    /**
     *
     * @param filename
     * @return
     * @throws IOException
     */
    public byte[] findFileFromHBase(String filename) throws IOException;

    /**
     *
     * @param vehicleID
     * @param startTime
     * @param endTime
     * @return
     * @throws IOException
     * @throws java.text.ParseException
     */
    public List<GPSInfo> scanHistroyDateWriteFile(String vehicleID, Date startTime, Date endTime) throws IOException, java.text.ParseException;
}
